import datetime
import threading
import time
import socket_setting
import socket_message
import socket
import user_class
Thread_Main:threading.Thread
Thread_Flag:bool=True
Mysocket:socket.socket
Str_Src:str=""
#开始socket线程
def thread_socket_start():
    global Thread_Main
    Thread_Main=threading.Thread(name='Thread_Main',target= thread_socket_main)
    Thread_Main.start()
#结束socket进程
def thread_socket_end():
    global Thread_Main,Thread_Flag
    Thread_Flag=False
#socket进程执行
def thread_socket_main():
    __start()
    while(Thread_Flag):  
        __accept_update()
    
    print("\033[92mGoodbye!\033[0m")

#socket执行开始
def __start():
    #print("\033[92m[Socket thread start]\033[0m")
    global Mysocket
    Mysocket=socket_setting.socket_init(socket_setting.Struct_Socket())
    #print("\033[92mSocket initialize completed\033[0m")
#socket执行帧
def __accept_update():
    global Mysocket,Str_Src
    conn:socket.socket=None
    add=None
    try:
        conn,add=Mysocket.accept()
        
    except:
        pass
    if(conn!=None):
        newplayer=user_class.User(conn,add[0],add[1])
        
        